package com.tradeplus.admin.dao;

import com.tradeplus.admin.model.Privilege;
import java.util.List;
import org.springframework.orm.hibernate3.HibernateTemplate;

public class PrivilegeDaoImpl implements PrivilegeDao {
    
    private HibernateTemplate hibernateTemplate;

    public void setHibernateTemplate(HibernateTemplate hibernateTemplate) {
        this.hibernateTemplate = hibernateTemplate;
    }

    @Override
    public void savePrivilege(Privilege privilege) {
        hibernateTemplate.merge(privilege);
    }

    @Override
    public List<Privilege> loadPrivilege() {
        return hibernateTemplate.find("from Privilege");
    }

    @Override
    public void deletePrivilege(Long privilegeId) {
        hibernateTemplate.delete(hibernateTemplate.get(Privilege.class, privilegeId));
    }

    @Override
    public Privilege loadPrivilegeById(Long privilegeId) {
        return (Privilege) hibernateTemplate.get(Privilege.class, privilegeId);
    }

}
